import crypto from 'crypto'
import { writeFileSync } from 'fs'
import { join } from 'path'

const generateSecret = () => crypto.randomBytes(32).toString('hex')

const envContent = `
NODE_ENV=development
PORT=3001
MONGODB_URI=mongodb://localhost:27017/live-platform
JWT_SECRET=${generateSecret()}
CLIENT_URL=http://localhost:3000
STREAM_SECRET=${generateSecret()}
`.trim()

const envPath = join(__dirname, '../../.env')
writeFileSync(envPath, envContent)
console.log('Generated .env file with default values')
